namespace Frameworks
{
    public class GUIProxyBase
    {
        private EventDispatcher _dispatcher;

        public GUIProxyBase()
        {
            Initialize();
        }

        private void Initialize()
        {
            _dispatcher = new EventDispatcher();
            InitEvent();
        }

        protected virtual void InitEvent() { }

        public virtual void Update() { }

        public virtual void Destroy()
        {
            if (_dispatcher != null)
                _dispatcher.Destory();
        }

        public bool AddEventListener(object eventType, EventListenerDelegate callback)
        {
            return _dispatcher.AddEventListener(eventType, callback);
        }

        public bool RemoveEventListener(object eventType)
        {
            return _dispatcher.RemoveEventListener(eventType);
        }

        public bool RemoveEventListener(object eventType, EventListenerDelegate callback)
        {
            return _dispatcher.RemoveEventListener(eventType, callback);
        }

        public void RemoveAllEventListeners()
        {
            _dispatcher.RemoveAll();
        }

        public bool BroadcastEvent(EventData eventData)
        {
            return _dispatcher.BroadcastEvent(eventData);
        }

        public bool BroadcastEvent(object eventType, object date)
        {
            EventData eventData = new EventData(eventType, date);
            return _dispatcher.BroadcastEvent(eventType, eventData);
        }

        public bool BroadcastEvent(object eventType, EventData data = null)
        {
            return _dispatcher.BroadcastEvent(eventType, data);
        }

        public bool HasEventListener(object type)
        {
            return _dispatcher.HasEventListener(type);
        }

        public bool HasEventListener(object type, EventListenerDelegate callback)
        {
            return _dispatcher.HasEventListener(type, callback);
        }
    }
}
